package com.luli.controllor;

import com.luli.entity.Menu;
import com.luli.entity.response.ResponseMsg;
import com.luli.service.MenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.luli.Utils.ResponseMsgUtil.getFailMsg;
import static com.luli.Utils.ResponseMsgUtil.getSuccessMsg;

/**
 * 陆离
 * 2022/11/16 13:37:59
 */
@RestController
@Slf4j
@RequestMapping("/menu")
@CrossOrigin
public class MenuController {

    @Autowired
    private MenuService menuService;

    @RequestMapping(value = "/queryUserRole", method = RequestMethod.GET)
    public ResponseMsg<?> queryUserCore(String roleId) {
        try {
            List<Menu> menus = menuService.queryUserRole(roleId);
            return getSuccessMsg(null, "查询成功"  , menus);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return getFailMsg(null, "查询失败", e.getMessage());
        }
    }
}
